package com.egg.mall.controller.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.egg.common.core.model.controller.ApiController;
import com.egg.common.core.model.response.ResponseData;
import com.egg.common.util.JsonUtil;
import com.egg.mall.entity.tag.TagSpu;
import com.egg.mall.model.response.api.TagSpuList;
import com.egg.mall.service.tag.ITagSpuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * @author east
 * @since 2023-05-09
 */
@Slf4j
@Api(tags = ApiController.API_PREFIX + "分组SPU")
@RestController
@RequestMapping("/tag/spu")
public class ApiTagSpuController extends ApiController {


    @Autowired
    private ITagSpuService tagSpuService;


    @ApiOperation(value = "分组SPU列表查询")
    @GetMapping("/list")
    public ResponseData<List<TagSpuList>> noticeListGet() {
        LambdaQueryWrapper<TagSpu> qw = tagSpuService.buildLambdaQw();
        qw.orderByDesc(TagSpu::getSort);
        List<TagSpu> list = tagSpuService.list(qw);
        List<TagSpuList> result = JsonUtil.listToList(list, TagSpuList.class);
        return ResponseData.success(result);
    }


}

